<?
class AppBaseLogadoController extends Zend_Controller_Action
{
	public $limit = 30;
	public $request;
	public $form;
	public $controller;
	public $action;
	public $usuario;
	public static $session = "";
	private $projeto = "";
	public $base = "certificadospp";
	public $titulo = "Certificado SPP";
	
	public function init()
	{
		$this->__getUrlAction();		
		$this->getIdentity();
		
		$this->view->projeto    = $this->projeto;
		$this->view->base       = "/$this->base/logado";
		$this->view->controller = $this->controller;
		$this->view->action     = $this->action;
		$this->view->usuario    = $this->usuario;
		$this->view->titulo    = $this->titulo;
		
		$usuario = new Zend_Session_Namespace('certificadospp');
		$this->view->usuario = $usuario;
	}

	public function __getUrlAction()
	{
		$parans = $this->_request->getParams();
		$url    = '';
		
		foreach ($parans as $key => $value)
		{
			if($key == 'module')
			{
				$value = ($value == 'default')?'':$value.'/';
				$url   = $value .$url;
				
				continue;
			}
			else if($key == 'controller')
			{
				$url .= $value.'/';
								
				$this->controller = $value;
			
				continue;
			}
			else if($key == 'action')
			{
				$url .= $value.'/';
				
				$this->action = $value;
				
				continue;
			}
			else if($key == 'pagina')
				continue;
			$url .= $key.'/'.$value.'/';
		}

		return $url;
	}
	
	public function getIdentity()
	{
		$usuario = new Zend_Session_Namespace('certificadospp');
		
		if(!$usuario->idusuario && ($this->controller != "login"))
		{
			$this->_redirect("/");
		}else{
			$this->usuario = $usuario;

			return $usuario->idusuario;
		}
	}
}
?>